var t = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}(require("../../../utils/api2"));

Page({
    data: {
        searchkey: "",
        noMore: !1
    },
    cancel: function() {
        this.setData({
            searchkey: ""
        });
    },
    saveSearchkey: function(t) {
        this.setData({
            searchkey: t.detail.value,
            hasSearched: !1
        });
    },
    search: function(t) {
        var e = this;
        clearTimeout(this.timer), this.timer = setTimeout(function() {
            e.loadSearchlist(e.data.searchkey);
        }, 20);
    },
    loadSearchlist: function(e) {
        var a = this, s = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
        t.default.site.home.searchlist({
            data: {
                keyword: e,
                offset: s ? 0 : this.data.searchList.length,
                limit: 10
            },
            desc: "获取查询结果"
        }).then(function(t) {
            var e = a.data.searchList;
            a.setData({
                searchList: s ? t.lists : e.concat(t.lists),
                noMore: t.lists.length < 10,
                hasSearched: !0
            });
        });
    },
    onReachBottom: function() {
        this.data.noMore || this.loadSearchlist(this.data.searchkey, !1);
    }
});